﻿using System;
using System.Collections.Generic;
using System.Data.Services;
using System.Data.Services.Common;
using System.Linq;
using System.ServiceModel.Web;
using System.Web;
using WcfDataServicesLibrary.Classes;

namespace WcfDataServicesLibrary
{
    public class CarService : DataService<Car>
    {
    	public IQueryable<Car> Cars
    	{
			get
			{
				return (new List<Car>
				       	{
							new Car {VIN = "ABC123",Make = "Ford", Model = "F-250", Year = 2000},
							new Car {VIN = "DEF123",Make = "BMW", Model = "Z-3", Year = 2005},
							new Car {VIN = "ABC456",Make = "Audi", Model = "TT", Year = 2008},
							new Car {VIN = "HIJ123",Make = "VW", Model = "Bug", Year = 1956},
							new Car {VIN = "DEF456",Make = "Ford", Model = "F-150", Year = 1998}
				       	}).AsQueryable();
			}
    	}

        // This method is called only once to initialize service-wide policies.
        public static void InitializeService(DataServiceConfiguration config)
        {
			config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
        }
    }
}
